package com.lovo.TestFile;

import java.util.Properties;

public class HomeWork {
    public static Properties p = new Properties();

    public static void main(String[] args) {
        // 将下面字符串?后面的键值对保存到properties文件中
        String url = "http://www.lovo.com/index?name=aaaaaa&age=20&gender=男";
        String url2 = null;
        String url4 = null;
        
        //拆分"/"
        String[] url1 = url.split("/");
        for (String obj : url1) {
            url2 = url1[3];
        }
        // System.out.println(url2);
        // 结果：index?name=aaaaaa&age=20&gender=男

        //拆分"?",需要进行转义处理
        String[] url3 = url2.split("\\?");
        for (String obj : url3) {
            url4 = url3[1];
        }
        // System.out.println(url4);
        // name=aaaaaa&age=20&gender=男


        //拆分"&" 和 "="
        String[] str = url4.split("&");
        for (String obj : str) {
            String[] str1 = obj.split("=");
            p.setProperty(str1[0], str1[1]);
        }

        PropertiesUtils.writeProperties("work.properties", p);
    }


}
